﻿using System;

//
// Created by Arosy on 2021/12/13.
//

//
// Created by Arosy on 2021/12/13.
//



/**
 * 字节码解释器
 */
public class BytecodeInterpreter
{
	public static bool run(JavaThread javaThread, MethodInfo methodInfo)
	{
		//取出字节码指令
		BytecodeStream bytecodeStream = methodInfo.getAttributeInfo()[0].getCode();
		int index = 0;
		while (index < bytecodeStream.getLength())
		{
			byte c = bytecodeStream.readByOne(ref index);
			Console.Write("指令字节：{0:X}\n", c);
			CodeRunBase.run[c](javaThread, bytecodeStream,ref index); //解释指令
		}
		Console.Write("===============执行方法结束 :{0} =================\n", methodInfo.getMethodName());
		return true;
	}
}


